<template>
	<view class="container">
		<web-view :webview-styles="webviewStyles" :src="goodsurl" v-if="platform!='app'"></web-view>
	</view>
</template>

<script>
	import core from "@/static/core.js"
	
	export default {
		data() {
			return {
				goodsid:0,
				goodsurl:'',
				platform:'',
				data:{
					title:"商品详情"
				},
				webviewStyles:{
					progress : false
				}
			}
		},
		onLoad(options) {
			if(typeof(options.id)=='undefined' || !options.id) return core.toast('参数错误：无效的商品ID','back');
			this.platform = core.platform;
			this.goodsid = options.id;
			let goodsurl = core.url('shop/goods','app') + '&id='+this.goodsid+(core.userinfo.uid==0?'':('&authkey='+core.userinfo.token));
			this.goodsurl = goodsurl;//.replace('swaapi.php','index.php');
			if(core.platform=='app'){
				let statusBarHeight = uni.getSystemInfoSync().statusBarHeight;
				let WindowHeight = uni.getSystemInfoSync().windowHeight;
				let w = plus.webview.create(this.goodsurl, 'id', {
					top: statusBarHeight ,//放置在titleNView下方。如果还想在webview上方加个地址栏的什么的，可以继续降低TOP值
					//因为设置top之后 webview的高度依然不变会往下移 底部会被遮住  所以设置一下高度
					height: WindowHeight - statusBarHeight,
				}, {
					preload: 'preload webview'
				});
				let currentWebview = this.$mp.page.$getAppWebview();
				currentWebview.append(w);
			}
		}
	}
</script>

<style>
</style>